#!/bin/bash

source /home/shell/util.sh
source /home/shell/jenkins/jenkins-util.sh

update_base_site=https://mirrors.huaweicloud.com/jenkins/plugins

if [[ -n "${1}" ]]; then
  download /var/lib/jenkins/plugins/$1.jpi ${update_base_site}/$1/latest/$1.hpi
else
  rm -rf /var/lib/jenkins/plugins/*

  for item in ${jenkins_plugins[*]}; do
    download /var/lib/jenkins/plugins/${item}.jpi ${update_base_site}/${item}/latest/${item}.hpi
  done
fi




systemctl restart jenkins
while [ -z "`tail /var/log/jenkins/jenkins.log|grep 'Jenkins is fully up and running'`" ]; do
  loadMsg "Jenkins即将完成重启..."
  sleep 1s 
done